package cn.lecosa.spark

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object Demo3 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf();
    val sc = new SparkContext(conf);

import org.apache.spark.streaming._
var ssc = new StreamingContext(sc, Seconds(2))
var lines = ssc.textFileStream("file:///home/software/data/mydata");
var result = lines.flatMap(_.split(" ")).map((_, 1)).reduceByKey(_ + _);
result.saveAsTextFiles("file:///home/software/data/mydata/abc.txt")
result.print()
ssc.start()

  }
}